package ifmo.compiler.task21.lexer.tokens;

import ifmo.compiler.task21.lexer.tokens.identifiers.IdentifierFactory;
import ifmo.compiler.task21.lexer.tokens.symbols.SymbolFactory;

/**
 * Factory to create tokens
 *
 * @author byaminov
 */
public class TokenFactory {

    public static Token createToken(TokenType type, String stringValue) {
        switch (type) {
            case DECIMAL:
                return new Decimal(stringValue);
            case FLOATING:
                return new Floating(stringValue);
            case IDENTIFIER:
                return IdentifierFactory.createToken(stringValue);
            case LINE_COMMENT:
                return new LineComment(stringValue);
            case RATIONAL:
                return new Rational(stringValue);
            case WS:
                return new Ws(stringValue);
            case END:
                return new End();
            case SYMBOL:
                return SymbolFactory.createToken(stringValue);
            default:
                return SymbolFactory.createToken(type);
        }
    }

}
